package com.example.hsh.homefragment.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ListView;

import com.example.hsh.homefragment.R;
import com.example.hsh.homefragment.adapter.ListViewAdapter;
import com.example.hsh.homefragment.adapter.TestAdapter;
import com.example.hsh.homefragment.rx.presenter.RxBasePresenter;
import com.example.hsh.homefragment.view.NestedScrollListView;

import java.util.ArrayList;

/**
 * Created by HSH on 2016/12/13.
 */

public class TestFragment extends BaseFragment {

    private RecyclerView recycler;
    private ArrayList<String> datas = new ArrayList<>();


    public static TestFragment newInstance() {
        Bundle args = new Bundle();

        TestFragment fragment = new TestFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected RxBasePresenter createPresenter() {
        return null;
    }

    @Override
    protected boolean userPresenter() {
        return false;
    }

    @Override
    protected void iniView(View rootView, @Nullable Bundle savedInstanceState) {
        recycler = (RecyclerView) rootView.findViewById(R.id.recycler);
        recycler.setLayoutManager(new LinearLayoutManager(mContext));
        TestAdapter testAdapter = new TestAdapter(mContext);
        testAdapter.addDatas(datas);
        recycler.setAdapter(testAdapter);

//        ListView testList = (ListView) rootView.findViewById(R.id.testList);
//        //21版本中已经支持了
//        testList.setNestedScrollingEnabled(true);
//        NestedScrollListView testList = (NestedScrollListView) rootView.findViewById(R.id.testList);
//        ListViewAdapter adapter = new ListViewAdapter(mContext);
//        adapter.addDatas(datas);
//        testList.setAdapter(adapter);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        for (int i=0;i<50;i++) {
            datas.add("test item ===" + i);
        }
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.layout_of_test_fragment;
    }
}
